home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 351-375 / 359 / dice / dice.lzh / lib / fd / fcntl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-01  |  650 b   |  43 lines

  1.  
  2. /*
  3.  *  FCNTL.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <ioctl.h>
  11. #include <fcntl.h>
  12. #include <errno.h>
  13.  
  14. int
  15. fcntl(fd, req, arg)
  16. int fd;
  17. int req;
  18. int arg;
  19. {
  20.     _IOFDS *d;
  21.  
  22.     switch(req) {
  23.     case F_DUPFD:
  24.     return(ioctl(fd, IOC_DUP, NULL));
  25.     case F_GETFD:
  26.     arg = -1;
  27.     ioctl(fd, IOF_GET|IOC_CEXEC, &arg);
  28.     return(arg);
  29.     case F_SETFD:
  30.     return(ioctl(fd, IOF_SET|IOC_CEXEC, &arg));
  31.     case F_GETFL:
  32.     arg = -1;
  33.     ioctl(fd, IOF_GET|IOC_MODES, &arg);
  34.     return(arg);
  35.     case F_SETFL:
  36.     return(ioctl(fd, IOF_SET|IOC_MODES, &arg));
  37.     }
  38.     errno = EBADF;
  39.     return(-1);
  40. }
  41.  
  42.  
  43.